<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>父向子</title>
</head>
<body>
<div id="app">
    我的num为 {{num}}
    <heima @increment="increment" @decrease="decrease"></heima>
</div>

<script src="./node_modules/vue/dist/vue.js"></script>
<script>
    var heima = {
        template: `
            <div>
            <button @click="increment">点我变大</button>
            <button @click="decrease">点我变小</button>
            </div>
        `,
        methods:{
            increment(){
                this.$emit("increment")
            },
            decrease(){
                this.$emit("decrease")
            }
        }


    };


    var app = new Vue({
        el: "#app",
        components: {
            heima
        },
        data: {
        num :18

        },
        methods:{
            increment(){
                this.num++
            },
            decrease(){
                this.num--
            }

        }

    })
</script>
</body>
</html>